package org.example.commodity.http;

import org.example.commodity.api.CommodityAPI;
import org.example.commodity.data.form.CommodityInfoForm;
import org.example.commodity.data.form.CommoditySearchForm;
import org.example.commodity.data.view.CommodityInfo;
import org.example.common.data.from.PageQueryForm;
import org.example.common.data.from.QueryForm;
import org.example.common.data.view.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/commodity")
public class CommodityController {

    @Autowired
    private CommodityAPI commodityAPI;

    @RequestMapping("/add")
    public CommodityInfo addCommodity(
            @RequestBody @Validated CommodityInfoForm commodityInfoForm){

        CommodityInfo commodityInfo = commodityAPI.addCommodity(commodityInfoForm);

        return commodityInfo;

    }

    @RequestMapping("/update")
    public CommodityInfo updateCommodity(
            @RequestBody @Validated CommodityInfoForm commodityInfoForm){

        CommodityInfo commodityInfo = commodityAPI.updateCommodity(commodityInfoForm);

        return commodityInfo;

    }

    @RequestMapping("/get")
    public CommodityInfo getCommodity(
            @RequestBody(required = false) QueryForm<CommoditySearchForm> commodityQuery){

        return null;

    }

    @RequestMapping("/get/batch")
    public List<CommodityInfo> batchGetCommodity(QueryForm<CommoditySearchForm> queryForm){
        return null;

    }

    @RequestMapping("/get/page")
    public PageInfo<CommodityInfo> pageGetCommodity(PageQueryForm<CommoditySearchForm> queryForm){
        return null;

    }

}
